import java.util.*;


public class Anagram {

public static void main (String[] args){
    final String ANAGRAM = "This is Anagram";
    final String NOT_ANAGRAM = "This is not an Anagram";

    String firstString = getString("first");
    String secondString = getString("second");

    if ((firstString.length() == secondString.length()) &&
	firstString.equals(secondString)){
	System.out.println(ANAGRAM);
	} else {
		System.out.println(NOT_ANAGRAM);
	}
}

    private static String getString(String stringNumber){
	System.out.print ("Enter "+stringNumber+" string: ");
        Scanner input = new Scanner(System.in);
        String str = input.nextLine().toLowerCase();
        char[] strArray = str.toCharArray();
        Arrays.sort(strArray);
	String rezult = String.valueOf(strArray).trim();
	return rezult;	
    }
}